﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.Threading.Tasks;

namespace SimpleRssReader.DataSources
{
    public static class DataSource
    {
        private static IDataSource _Instance;
        private static CachedDataSource _CachedInstance;

        public static IDataSource Instance
        {
            get 
            {
                if (_Instance == null)
                {
                    lock (typeof(DataSource))
                    {
                        if (_Instance == null)
                        {
                            _Instance = new RssDataSource();
                        }                    
                    }
                }
                return _Instance; 
            }
        }

        public static CachedDataSource CachedInstance
        {
            get
            {
                if (_CachedInstance == null)
                {
                    lock (typeof(DataSource))
                    {
                        if (_CachedInstance == null)
                        {
                            _CachedInstance = new CachedDataSource(Instance);
                        }
                    }
                }
                return _CachedInstance;
            }
        }
    }
}
